# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=direnv
pkgver=2.33.0
pkgrel=0
pkgdesc="Environment variable switcher for the shell"
url="https://direnv.net"
license="MIT"
arch="all"
depends="bash"
makedepends="go"
subpackages="$pkgname-doc $pkgname-fish::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/direnv/direnv/archive/v$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make
}

check() {
	# Also has tests for tcsh and elvish, this manual call is done instead of
	# tests to avoid unwanted tests like 'shellcheck' and 'go-fmt'
	make test-go test-bash
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install
}

fish() {
	pkgdesc="configuration hooks for fish"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	amove usr/share/fish/vendor_conf.d
}

sha512sums="
65aff9194532d0e3436ce2d71274737a55876b76caad90ffa02e4f7d71bd1da9b07d867404b8cfc46fd508c95d5f3a30fbb17af9cfcccf2400db55e8ff4a38ee  direnv-2.33.0.tar.gz
"
